package com.ajun.controller;

import com.ajun.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/api/payment/hystrix")
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    /**
     * 正常访问
     */
    @GetMapping("/ok/{id}")
    public String infoOk(@PathVariable("id") Integer id) {
        String result = paymentService.infoOk(id);
        log.info("### result -> " + result);
        return result;
    }

    /**
     * 错误访问
     */
    @GetMapping("/timeout/{id}")
    public String infoTimeOut(@PathVariable("id") Integer id) {
        String result = paymentService.infoTimeOut(id);
        log.info("### result -> " + result);
        return result;
    }
}
